package com.ghovos.usermangerpgdemo.common.exception;

import com.ghovos.usermangerpgdemo.common.result.GlobalResultEnum;
import lombok.Data;

/**
 * @author EdgarLiu(刘凌峰)
 * date: 2022/3/17
 * time: 上午10:43
 * email: EdgarLlf@foxmail.com
 */
@Data
public class GlobalException extends RuntimeException {
   private Integer code;

   public GlobalException(String msg, Integer code) {
      super(msg);
      this.code = code;
   }

   public GlobalException(GlobalResultEnum globalResultEnum) {
      super(globalResultEnum.getMessage());
      this.code = globalResultEnum.getCode();
   }

   @Override
   public String toString() {
      return "GlobalException{" +
              "code= " + code +
              ", message= " + this.getMessage() +
              "}";
   }
}
